package com.itheima.service;

import java.sql.SQLException;
import java.util.List;

import com.itheima.bean.Product;
import com.itheima.dao.ProductDao;

public class ProductService {

	/**
	 * 查询所有商品
	 * @return
	 * @throws SQLException 
	 */
	public List<Product> findAll() throws SQLException {
		ProductDao pd = new ProductDao();
		return pd.findAll();
	}
	/**
	 * 增加商品
	 * @param pro
	 * @throws SQLException 
	 */
	public void saveProduct(Product pro) throws SQLException {
		ProductDao pd = new ProductDao();
		pd.saveProduct(pro);
	}
	/**
	 * 根据id查询数据
	 * @param id
	 * @return
	 * @throws SQLException 
	 */
	public Product getProByPid(String id) throws SQLException {
		ProductDao pd = new ProductDao();
		return pd.getProByPid(id);
	}
	/**
	 * 根据id更新商品
	 * @param pro
	 * @throws SQLException 
	 */
	public void updatePro(Product pro) throws SQLException {
		ProductDao pd = new ProductDao();
		pd.updatePro(pro);
	}
	/**
	 * 根据id删除商品信息
	 * @param pid
	 * @throws SQLException 
	 */
	public void deletePro(String pid) throws SQLException {
		ProductDao pd = new ProductDao();
		pd.deletePro(pid);
	}

}
